import keyboard
from keyboard import KeyboardEvent


def fn1(e: KeyboardEvent):
    print(e.name)

if __name__ == '__main__':
    keyboard.on_press(fn1)
    keyboard.wait('esc')